/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tools;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Rezha
 */
public class socketHelper {

    public static Socket getSocketConnection(String host,int port){
        try {
            Socket temp = new Socket(host, port);
            return temp;
        } catch (UnknownHostException ex) {
            Logger.getLogger(socketHelper.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(socketHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public static DataOutputStream getWriter(Socket sock){
        try {
            return new DataOutputStream(sock.getOutputStream());
        } catch (IOException ex) {
            Logger.getLogger(socketHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public static DataInputStream getReader(Socket sock){
        try {
            return new DataInputStream(sock.getInputStream());
        } catch (IOException ex) {
            Logger.getLogger(socketHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
